﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Infraestruturex.BaseLibrary;
using Infraestruturex.Automata;
using Compilex.Syntatic.Declarations;

namespace Compilex.Syntatic
{
    public class SyntaticContext
    {
        public SimpleStack<string> SyntaticStack { get; set; }
        public ITokenProvider TokenProvider { get; set; }
        public string CurrentToken { get { return TokenProvider.PeekNextTokenLexeme(); } }
        public ScopeManager ScopeManager { get; set; }

        public ActionInfo LastAction { get; set; }
        public enum ActionInfo
        {
            VariableDeclared,
            ArrayDeclared
        }

        public VariableDeclaration VariableDeclaration { get; set; }
        public FunctionDeclaration FunctionDeclaration { get; set; }
        public Assignment Assignment { get; set; }
        //public ArithmeticExpression ArithmeticExpression { get; set; }
        public ExpressionStack ExpressionStack { get; set; }
        //public CodeGenerator CodeGenerator { get; set; }
        public CommandBlockStack CommandBlockStack { get; set; }
        public FunctionCallStack FunctionCallStack { get; set; }
         

        public SyntaticContext()
        {
            this.SyntaticStack = new SimpleStack<string>();
            this.ScopeManager = new ScopeManager();
            this.VariableDeclaration = new VariableDeclaration(this);
            this.FunctionDeclaration = new FunctionDeclaration(this);
            this.Assignment = new Assignment(this);
            //this.ArithmeticExpression = new ArithmeticExpression(this);
            this.ExpressionStack = new ExpressionStack(this);
            this.FunctionCallStack = new FunctionCallStack(this);

            //this.CodeGenerator = new CodeGenerator(this);
            this.CommandBlockStack = new CommandBlockStack(this);
        }

        public void PushCurrentToken()
        {
            SyntaticStack.Push(CurrentToken);
        }
    }
}
